﻿using System.Collections.Generic;
using System.Text;

namespace Ex03.GarageLogic
{
    /// <summary>
    /// This class is for an Fuel Powered Car
    /// Inherits from Fuel Powered Vehicle
    /// </summary>
    public class FuelPoweredCar : FuelPoweredVehicle
    {
        private const float k_FuelTankCapacityInLitres = 42;
        private const eFuelType k_FuelType = eFuelType.Octan95;
        private static readonly Dictionary<string, string> sr_FuelPoweredCarForm;

        private CarData m_Data;

        /// <summary>
        /// This is a static constructor that will initialize the Fuel 
        /// Powered Car form 
        /// </summary>
        static FuelPoweredCar()
        {
            sr_FuelPoweredCarForm = new Dictionary<string, string>(FuelPoweredVehicleForm);
            foreach (KeyValuePair<string, string> keyValuePair in CarData.CarDataForm)
            {
                sr_FuelPoweredCarForm.Add(keyValuePair.Key, keyValuePair.Value);
            }
        }

        /// <summary>
        /// A constructor that will pass all input to its base
        /// </summary>
        /// <param name="i_PlateNumber">plate number needed by parent </param>
        /// <param name="i_NumberOfWheels">number of wheels needed by parent</param>
        /// <param name="i_WheelMaxAirPressure">wheel max air pressure needed by parent</param>
        public FuelPoweredCar(string i_PlateNumber)
            : base(i_PlateNumber, CarData.k_NumberOfWheels, CarData.k_MaxAirPressureOfWheels)
        {         
        }

        /// <summary>
        /// This is the main initialization function of this object
        /// This function will receive a form with all the data needed for the initialization
        /// </summary>
        /// <param name="i_CreationForm">A key value Dictionary where key is the name of the member 
        /// to initialize and value is the new value
        /// </param>
        public override void Initialize(Dictionary<string, string> i_CreationForm)
        {
            base.Initialize(i_CreationForm);
            m_Data = new CarData(i_CreationForm);
        }

        /// <summary>
        /// A property to get the Number Of Wheels
        /// </summary>
        public int NumberOfWheels
        {
            get { return CarData.k_NumberOfWheels; }
        }

        /// <summary>
        /// A property to get the Max Air Pressure Of Wheels
        /// </summary>
        public float MaxAirPressureOfWheels
        {
            get { return CarData.k_MaxAirPressureOfWheels; }
        }

        /// <summary>
        /// A property to get the Fuel Type
        /// </summary>
        public override eFuelType FuelType
        {
            get { return k_FuelType; }
        }

        /// <summary>
        /// A property to get the Fuel Capacity In Liters
        /// </summary>
        public override float FuelCapacityInLitres
        {
            get { return k_FuelTankCapacityInLitres; }
        }

        /// <summary>
        /// A method to get the form of the Fuel Powered Car 
        /// </summary>
        public override Dictionary<string, string> GetForm()
        {
            return new Dictionary<string, string>(sr_FuelPoweredCarForm);
        }

        /// <summary>
        /// Return a string representation object members as pair 
        /// members name and variable value
        /// </summary>
        /// <returns>string "varName + Vehicle.k_ToStirngPairDelimiter + varValue + Vehicle.sr_ToStirngEndOfPairDelimiter"</returns>
        public override string ToString()
        {
            StringBuilder stringBuilderResult = new StringBuilder();

            stringBuilderResult.Append(base.ToString());
            stringBuilderResult.Append(m_Data.ToString());

            return stringBuilderResult.ToString();
        }
    }
}
